{extend name='common/common' /}

{block name="content"}
<el-card class="box-card">
	<div slot="header">
		<span class="span-primary"><i class="fa fa-list"></i></span>
		企业列表
	</div>
	<div class="el-card-content">
		<el-table :data="table.tableData" border>
			<el-table-column align="center" prop="id" label="序号" width="50"></el-table-column>
			<el-table-column align="center" label="企业名称" prop="name"></el-table-column>
			<el-table-column align="center" label="所属地区" prop="depart_name"></el-table-column>
			<el-table-column align="center" label="联系人" prop="link_man"></el-table-column>
			<el-table-column align="center" label="电话" prop="tel"></el-table-column>
			<el-table-column align="center" label="操作">
				<template slot-scope="scope">
					{if authCheck('webshop/webshoplistincompany')}
					<el-tooltip content="网店列表" open-delay="500" hide-after="1500" placement="bottom">
						<el-button
							@click="WebShopList(scope.row)"
							size="mini" plain type="primary"
							icon="fa fa-list">
						</el-button>
					</el-tooltip>
					{/if}
					{if authCheck('commit/webshoptable')}
					<el-tooltip content="填写报表" open-delay="500" hide-after="1500" placement="bottom">
						<el-button
							@click="WebShopTable(scope.row)"
							size="mini" plain type="success"
							icon="fa fa-table">
						</el-button>
					</el-tooltip>
					{/if}
					{if authCheck('commit/webshoptablelist')}
					<el-tooltip content="查看报表" open-delay="500" hide-after="1500" placement="bottom">
						<el-button
							@click="WebShopTableList(scope.row)"
							size="mini" plain type="success"
							icon="fa fa-table">
						</el-button>
					</el-tooltip>
					{/if}
				</template>
			</el-table-column>
		</el-table>
		<div class="table-page">
			<el-pagination
				@size-change="pageSizeChange"
				@current-change="curPageChange"
				:current-page="table.pageNumber"
				:page-sizes="[10, 20, 50, 75]"
				:page-size="table.pageSize"
				layout="total, sizes, prev, pager, next, jumper"
				:total="table.tableTotal">
			</el-pagination>
		</div>
	</div>
</el-card>
{/block}

{block name="script"}
<script type="text/javascript">
var main = new Vue({
	el:"#main",
	data:{
		loading:false,
		rptDate:"",
		table:{
			tableData:"",
			pageSize:10,
			pageNumber:1,
			tableTotal:0,
		}
	},
	mounted:function() {
		this.getTable();
	},
	methods:{
		getTable() {
			this.loading=true;
			var param = {
				pageSize:this.table.pageSize,
				pageNumber:this.table.pageNumber,
			};
			$.post('{:url("Users/CompanyList")}',param,function(res){
				main.loading=false;
				if(res.code == 1){
					main.$message({message: res.msg,type: 'success'});
					main.table.tableData = res.data.rows;
					main.table.tableTotal = res.data.total;
				}else{
					main.$notify.error({title: '失败',message: res.msg});
				}
			});
		},
		pageSizeChange(val) {
			this.table.pageSize = val;
			this.getTable();
		},
		curPageChange(val) {
			this.table.pageNumber = val;
			this.getTable();
		},
		WebShopList(row) {
			var url = '{:url("Webshop/webshopListInCompany")}?company_id='+row.id;
			window.location.href = url;
		},
		WebShopTable(row) {
			var url = '{:url("Commit/webshopTable")}?company_id='+row.id;
			window.location.href = url;
		}
	}
})
</script>
{/block}
